const Koa = require("koa");
const parser = require("koa-parser");
const router = require("koa-router")();
const app = new Koa();


app.use(router.routes());
app.use(parser());

//接受暴露文件
let routers = require("./index");

console.log(routers);

for(let r in routers){
    let type = routers[r][0];
    let fn = routers[r][1];
    if(type === "get"){
        router.get(r,fn);
    }else{
        router.post(r,fn);
    }
}



app.listen(3000,()=>{
    console.log("服务器运行的地址是:htpp://127.0.0.1:3000");
})

